package com.tuling.spring;

import com.tuling.UserInterface;
import com.tuling.UserService;
import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 基于beanName的匹配规则作代理增强
 * {@link BeanNameAutoProxyCreator#setBeanNames(String...)}
 */
public class AspectDemo {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AspectDemo.class, AspectConfig.class);
		UserInterface userInterface = (UserInterface) context.getBean("userService");
		userInterface.test();
		System.out.println(":::::::::::::::::::::::::::::::::::::::::::");
		userInterface.test("hello world....");
		System.out.println(":::::::::::::::::::::::::::::::::::::::::::");
		userInterface.testA();
		System.out.println(":::::::::::::::::::::::::::::::::::::::::::");
		userInterface.testB();
		System.out.println(":::::::::::::::::::::::::::::::::::::::::::");
	}

	@Bean
	public UserService userService() {
		return new UserService();
	}
}
